Refactored some reduntant code
Final touches done