made code more type safe