Wrote functions for frequently used codes