split up long function