reducing function complexity