code clean up & tests added