Refactored some unnec code