fixed condtional, needs refactoring