refactored the functions