working functions

working functions with comments