updated code structure

cleaned code structure up for clarity