Fixed timing bug and added sec sleep