refined functions, tested four days