Ported from meteor to webapp