Cleaned code and refactoring