code restructure

cleaner code structure