Removed extra if conditions and anded the conditions