refactor pop method for empty stack