update with new PR, better solution to the problem