Added response timer and cleaned up code