rewrote javascript for cards towards more namespaced and elegant code