Removed unncessary code and optimized a little