Refactored but not working