working on functions to make it all nicer