refactor start and stop script