all functions copypasted, compiles