Removed some if and added loops instead to process the conditions.