fixed pre_user script
moved functions to extra file