useful functions for various stages of page loasd