refactored the protorype