less error prone solution for same issue as previous commit