solving coding problem