Function nearly works fine.