fix pop to make sure stack is not null
fix code check