cleaned up code for timing