separated the functions, so it's more like #1278. should be faster in theory