added length checks and timer