Add promises to reduce code clutter (fix #6)