function before ready