added functions to header + fit text
moved main() to the top