update pop method for check for empty