method or algorithm for controlling doors