Simplified and broke down most logic into more methods