Fixed and refactored