fixed last minute bugs
allow it to return correct results