basic version, tested locally on function level