cleaned up some function and easier to get a grasp of whats going on