Added functions and procedure