small changes to reduce code duplication

Signed-off-by: Andrew <a@0x41.co>