fixed wrong subroutine ending