initial solution
complete version