made code functional