functions changed and comments added