Fixed a bug in selectBy method