Cleaned up the code

Made the code more compact