Got rid of unnecessary inner function