Cleaned up registerCommand method