changestatus function wrapped inside a transaction