solved, hope can be more efficient