check if possible to move latch into python code