Removing superfolous if function