refactored how subroutine is implemented
implemented WHILE