fixed push_whack_pop to also handle directories