publish modification

moved var assignment to top, added type warning