fixed bug. now reset offset on valid input