Made more object oriented, need to test if it works