Added missing end and removed unnecessary returns