add return -1 and check some conditions