fix bugs with procedures