Cleaned up code after refactoring