fixed tabs
added type checks for sorting