added functions and cleaned up file structure