Switched out code for a unit tested version