Trying to clean up the code