Figured out some algorithms necessary