Fixed Conditional and refactored