fix with another approach due to casting issues with the previous attempt