moved more functions into helperfunctions 

moved more functions into helperfunctions file and added comments