a hack: used goto to deallocate the first empty frame. Not pretty but it should be efficient.