fixed functions
formatted code