completet rewrote using ionic platform