fixed functions and date converting