cleaning up and moving to functions