added time limits
fixed discritization