Removed echo statements, replaced with return statements