fixing and refactoring delay