Fixed 500 error when changing date range