partially functions optimize + fixing