Cleaned up the code