cleaned up the code more