date format math and conditionals fixed