code refactored

Works!!