Cleaning up the names; generalizing the code