basic refactor code and rearrangement