upd: add time delay and refactor