implememting solution to FOUC per @rwinikates suggestion