fixed function returning more than 1 row