Fix for switching to previous buffer

Added fix to correctly handle switching to previous buffer after command.