Fixed onpause() bug