[1663] Added with statment, bugs corrected