wrote sign extend function